home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 1174 / text0000.txt < prev   
Encoding:
Text File  |  1996-08-06  |  843 b   |  28 lines

  1. >>>>> Andrew Bell <abell@mindspring.com> writes:
  2.  
  3. > One problem, though, is that you may not care about the actual class
  4. > of an object, but just whether it is derived from (or is) of a
  5. > particular class, and RTTI doesn't help you there.
  6.  
  7. Why do you say that?  That's precisely what dynamic_cast is for.
  8.  
  9.  
  10. ...
  11.  
  12.   typedef class_where_method_is_introduced T;
  13.   if (T* p = dynamic_cast<T*>(generic_ptr))
  14.     {
  15.       p->method ();
  16.     }
  17.  
  18. ...
  19.  
  20. Jason
  21.  
  22.  
  23. [ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
  24. [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
  25. [ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
  26. [ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
  27. [ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
  28.